﻿using AutoMapper;
using DbModel.Models;
using DbModel.ViewModel.Question;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Extensions.AutoMapper
{
    public class QuestionProfile : Profile
    {
        public QuestionProfile()
        {
            CreateMap<CreateQuestionInputDto, Question>();
            CreateMap<UpdateQuestionInputDto, Question>();
            CreateMap<Question, QuestionDto>().ForMember(a => a.QuestionCommentCount, o => o.MapFrom(x => x.QuestionComments.Count));
            CreateMap<Question, QuestionDetailsDto>();
            CreateMap<QuestionComment, QuestionCommentDto>().ForMember(a => a.UserName, o => o.MapFrom(x => x.CreateUser.UserName))
                .ForMember(a => a.HeadPortrait, o => o.MapFrom(x => x.CreateUser.HeadPortrait));
            CreateMap<CreateQuestionCommentsInputDto, QuestionComment>();
        }
    }
}
